from flask import Blueprint, jsonify, request
from app.services.activity_service import ActivityService
from app.utils.errors import handle_error

activity_bp = Blueprint("activity", __name__)


@activity_bp.route("/", methods=["POST"])
def record_activity():
    data = request.get_json()
    try:
        activity = ActivityService.create_activity(data)
        return jsonify(activity.to_dict()), 201
    except ValueError as e:
        return handle_error(str(e), 400)
